package com.wgts.wgts.mvp.presenter.imp;

import com.wgts.wgts.mvp.model.IGuessingAndAwardDetailsActivityModel;
import com.wgts.wgts.mvp.presenter.IGuessingAndAwardDetailsActivityPresenter;
import com.wgts.wgts.mvp.view.IGuessingAndAwardDetailsActivityView;
import com.wgts.wgts.netmodle.HttpResultSubscriber;
import com.wgts.wgts.netmodle.resp.AwardWinnerDetail;
import com.wgts.wgts.netmodle.resp.CurrentEntity;

public class GuessingAndAwardDetailsActivityPresenter implements IGuessingAndAwardDetailsActivityPresenter {

    private IGuessingAndAwardDetailsActivityModel model;

    private IGuessingAndAwardDetailsActivityView view;

    public GuessingAndAwardDetailsActivityPresenter(IGuessingAndAwardDetailsActivityModel model, IGuessingAndAwardDetailsActivityView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void initView(Integer winnId) {
        model.initView(winnId, new HttpResultSubscriber<AwardWinnerDetail>() {
            @Override
            public void onSuccess(AwardWinnerDetail awardWinnerDetail) {
                view.initViewResult(awardWinnerDetail);
            }

            @Override
            public void _onError(int status, String msg) {
                view.onError(status, msg);
            }
        });
    }

    @Override
    public void ensureAwardOrder(Integer winnId) {
        model.ensureAwardOrder(winnId, new HttpResultSubscriber<CurrentEntity>() {
            @Override
            public void onSuccess(CurrentEntity currentEntity) {
                view.ensureSuccess();
            }

            @Override
            public void _onError(int status, String msg) {
                view.onError(status, msg);
            }
        });
    }
}
